# coding: utf-8
# @Author : lryself
# @Date : 2020/10/20 23:41
# @Software: PyCharm

from flask import render_template, redirect, request, url_for
from flask_login import logout_user, login_required
from . import view


@view.route('/login', methods=('GET', 'POST'), endpoint='login')
def login():
    next_url = request.args.get("next")
    return render_template('login.html', next_url=next_url if next_url else url_for("views./"))


@view.route('/logout', methods=('GET', 'POST'), endpoint="logout")
def logout():
    logout_user()
    return redirect('/')


@view.route('/register', methods=('GET', 'POST'), endpoint='register')
def register():
    return render_template('register.html')


@view.route('/change_password', methods=('GET', 'POST'), endpoint='change_password')
@login_required
def change_password():
    return render_template('change_password.html')